﻿//comment for ian
package 
{
    public class NameThatCompoundQuestion 
    {
		public var Answer:String = "";
		public var Images:String = "";
		public var Level:String = "";
		public var Hint:String = "";
		public var Aliases:String = "";
		private var AliasesSplit:Array = new Array();
		private var ImagesSplit:Array = new Array();
		private var LastImageUsed:Number = 0;
		public function GetImage():String
		{
			if (Images != null && Images != "" && ImagesSplit.length == 0)
			{
				ImagesSplit = Images.split(";");
			}
			if (this.LastImageUsed >= ImagesSplit.length - 1)
			{
				this.LastImageUsed = 0;
			}
			else
				this.LastImageUsed++;
			return ImagesSplit[this.LastImageUsed];
			
		}
		public function AmIRightSoFar(test:String):Boolean
		{
			if (Aliases != null && Aliases != "" && AliasesSplit.length == 0)
			{
				AliasesSplit = Aliases.split("|");
			}
			if (test == "")
				return true;
			if (Answer == test)
				return true;
			if (Answer.substr(0, test.length) == test)
				return true;
			for each (var aka:String in AliasesSplit)
			{
				if (aka == test)
					return true;
				if (aka.substr(0, test.length) == test)
					return true;
			}
			return false;
		}
		public function GetAnswers():String
		{
			if (Aliases != null && Aliases != "" && AliasesSplit.length == 0)
			{
				AliasesSplit = Aliases.split("|");
			}
			var returnVal:String = Answer;
			if (AliasesSplit.length > 0)
			{
				
				for (var index:int = 0; index < AliasesSplit.length - 1; index++)
				{
					returnVal += ", " + AliasesSplit[index];
				}
				returnVal += " or " + AliasesSplit[AliasesSplit.length - 1];
				
			}
			return returnVal;
		}
		public function AmIExactlyRight(test:String):Boolean
		{
			if (Aliases != null && Aliases != "" && AliasesSplit.length == 0)
			{
				AliasesSplit = Aliases.split("|");
			}
			if (Answer == test)
				return true;
			for each (var aka:String in AliasesSplit)
			{
				if (aka == test)
					return true;
			}
			return false;
		}
	}
}